/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ru.jSkyRoom.bridge.major;

import java.util.Collection;
import java.util.Collections;
import ru.jSkyRoom.bridge.sub.ResponseBridge;
import ru.jSkyRoom.interfaces.major.Info;
import ru.jSkyRoom.interfaces.major.NPC;
import ru.jSkyRoom.interfaces.stub.JSkyScriptPackage;
import ru.jSkyRoom.interfaces.stub.JSkySound;
import ru.jSkyRoom.interfaces.stub.ResponseData;
import ru.jSkyRoom.interfaces.sub.JSkyResponse;
import skyproc.Condition;
import skyproc.FormID;
import skyproc.INFO;
import skyproc.INFO.Response;
import skyproc.ScriptPackage;
import skyproc.genenums.FavorLevel;

/**
 *
 * @author Rakev
 */
public class InfoBridge extends MajorBridge<INFO> implements Info {

    public InfoBridge(INFO adapting) {
        super(adapting);
    }

    @Override
    public JSkyScriptPackage getScriptPackage() {
        ScriptPackage scriptPackage = getRawObject().getScriptPackage();
        return getBridgeFactory().createBridge(scriptPackage);
    }

    @Override
    public boolean get(INFO.ResponseFlag flag) {
        return getRawObject().get(flag);
    }

    @Override
    public void set(INFO.ResponseFlag flag) {
        getRawObject().set(flag, true);
    }

    @Override
    public void unset(INFO.ResponseFlag flag) {
        getRawObject().set(flag, false);
    }

    @Override
    public float getResetTime() {
        return getResetTime();
    }

    @Override
    public void setResetTime(float hours) {
        getRawObject().setResetTime(hours);
    }

    @Override
    public Info getTopic() {
        FormID id = getRawObject().getTopic();
        return getFinderFactory().createInfoFinder().find(id);
    }

    @Override
    public void setTopic(Info topic) {
        FormID id = getIdProducer().produce(topic);
        getRawObject().setTopic(id);
    }

    @Override
    public Info getPrevious() {
        FormID id = getRawObject().getPreviousINFO();
        return getFinderFactory().createInfoFinder().find(id);
    }

    @Override
    public void setPrevious(Info previous) {
        FormID id = getIdProducer().produce(previous);
        getRawObject().setPreviousINFO(id);
    }

    @Override
    public FavorLevel getFavorLevel() {
        return getRawObject().getFavorLevel();
    }

    @Override
    public void setFavorLevel(FavorLevel lev) {
        getRawObject().setFavorLevel(lev);
    }

    @Override
    public Collection<Info> getTopicLinks() {
        Collection<FormID> ids = getRawObject().getLinkTo();
        Collection<Info> result = getFinderFactory().createInfoFinder().find(ids);
        return Collections.unmodifiableCollection(result);
    }

    @Override
    public void addTopicLink(Info link) {
        FormID id = getIdProducer().produce(link);
        getRawObject().addLinkTo(id);
    }

    @Override
    public void removeTopicLink(Info link) {
        FormID id = getIdProducer().produce(link);
        getRawObject().removeLinkTo(id);
    }

    @Override
    public ResponseData getResponseData() {
        FormID id = getRawObject().getResponseData();
        return getFinderFactory().createResponseDataFinder().find(id);
    }

    @Override
    public void setResponseData(ResponseData response) {
        FormID id = getIdProducer().produce(response);
        getRawObject().setResponseData(id);
    }

    @Override
    public Collection<Condition> getConditions() {
        Collection<Condition> result = getRawObject().getConditions();
        return Collections.unmodifiableCollection(result);
    }

    @Override
    public void addCondition(Condition condition) {
        getRawObject().addCondition(condition);
    }

    @Override
    public void removeCondition(Condition condition) {
        getRawObject().removeCondition(condition);
    }

    @Override
    public Collection<JSkyResponse> getResponses() {
        Collection<Response> raws = getRawObject().getResponses();
        Collection<ResponseBridge> result = getBridgeFactory().createBridges(raws, ResponseBridge.class);
        return Collections.unmodifiableCollection((Collection) result);
    }

    @Override
    public String getPrompt() {
        return getRawObject().getPrompt();
    }

    @Override
    public void setPrompt(String text) {
        getRawObject().setPrompt(text);
    }

    @Override
    public NPC getSpeaker() {
        FormID id = getRawObject().getSpeaker();
        return getFinderFactory().createNPCFinder().find(id);
    }

    @Override
    public void setSpeaker(NPC speaker) {
        FormID id = getIdProducer().produce(speaker);
        getRawObject().setSpeaker(id);
    }

    @Override
    public Info getWalkAwayTopic() {
        FormID id = getRawObject().getWalkAwayTopic();
        return getFinderFactory().createInfoFinder().find(id);
    }

    @Override
    public void setWalkAwayTopic(Info topic) {
        FormID id = getIdProducer().produce(topic);
        getRawObject().setWalkAwayTopic(id);
    }

    @Override
    public JSkySound getAudioOverride() {
        FormID id = getRawObject().getAudioOverride();
        return getFinderFactory().createJSkySoundFinder().find(id);
    }

    @Override
    public void setAudioOverride(JSkySound sound) {
        FormID id = getIdProducer().produce(sound);
        getRawObject().setAudioOverride(id);
    }
}
